<html>
<style>
div{
height:160px;
width:160px;
color:red;
float:left;
margin:10px;
}
</style>
<body>
<script type="text/javascript">

var i;
for(i=0;i<30;i++)
{
	document.write("<div></div>");
}
window.setInterval("setColor()",1000);
function setColor()
{
	var divs=document.getElementsByTagName("div");
//	alert(divs.length);
	for(i=0;i<divs.length;i++)
	{var colorValue;
	colorValue= parseInt(Math.random()*0xffffff).toString(16);
	divs[i].innerHTML=colorValue;
		divs[i].style.backgroundColor=colorValue;
	}
}
</script>

</body>
</html>